﻿using System.Collections.Generic;

namespace Inovout.Gis
{
    public class GroupLayerObject : LayerObject, IGroupLayerObject,IGroupLayerInfo
    {
        internal GroupLayerObject()
            : this(null)
        {
        }
        public GroupLayerObject(IGroupLayerInfo groupLayerInfo)
            : base(groupLayerInfo)
        {
        }


        private List<ILayerObject> layers;
        public List<ILayerObject> Layers
        {
            get
            {
                if (layers == null)
                {
                    layers = new List<ILayerObject>();
                    foreach (ILayerInfo layerInfo in ((IGroupLayerInfo)LayerInfo).Layers)
                    {
                        LayerObject layerElement = layerInfo as LayerObject;
                        if (layerElement != null)
                        {
                            layerElement.Owner = this;
                            layers.Add(layerElement);
                        }
                    }
                }
                return layers;
            }
        }

        List<ILayerInfo> IGroupLayerInfo.Layers
        {
            get { return ((IGroupLayerInfo)LayerInfo).Layers; }
        }
    }
}
